import { UPDATEPAGEEDUCATIONINFORMATION } from '../types/pageeducationinformation'
import { createAction } from 'redux-actions'
import {
  insertEducationRequest,
  updateEducationRequest
} from '../../../../service/user-archive-controller'

const formatdata = entry => {
  return {
    text: '开始啪啪啪'
  }
}

export const DOREQUESTEDUCATIONINFORMATION = createAction(
  UPDATEPAGEEDUCATIONINFORMATION,
  payload => {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve({
          ...formatdata()
        })
      }, 1000)
      // doRequesttest({...payload}).then(({data}) => {
      // 	const {networkerror, entry, status, message} = data
      // 	if (networkerror) {
      // 		resolve({
      // 			networkerror: true
      // 		})
      // 	} else {
      // 		if (status && entry) {
      // 			let dataformat = formatdata(entry)
      // 			resolve({
      // 				networkerror: false,
      // 				showEmpty:false,
      // 				...dataformat
      // 			})
      // 		} else {
      // 			resolve({
      // 				networkerror: false,
      // 				showEmpty:true
      // 			})
      // 		}
      //
      // 	}
      // })
    })
  }
)

export const DOREQUESTESUBMIT = payload => {
  return new Promise(resolve => {
    insertEducationRequest({ ...payload }).then(({ data }) => {
      const { networkerror, entry, status, message } = data
      resolve({
        status,
        message
      })
    })
  })
}

export const DOREQUESTEEDITEDU = payload => {
  return new Promise(resolve => {
    updateEducationRequest(payload).then(({ data }) => {
      const { networkerror, entry, status, message } = data
      resolve({
        status,
        message
      })
    })
  })
}
